version: '3.1'
services:
  stats-server:
    build: stats-service/stats-server
    image: stats-server
    container_name: stats-server
    ports:
      - "9090:9090"
    depends_on:
      - stats-db
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://stats-db:5432/stats-db
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password

  stats-db:
    image: postgres:13.7-alpine
    container_name: stats-db
    ports:
      - "6542:5432"
    environment:
      - POSTGRES_DB=stats-db
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password

  ewm-service:
    build: ewm-service
    image: ewm-service
    container_name: ewm_service
    ports:
      - "8080:8080"
    depends_on:
      - ewm-db
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://ewm-db:5432/ewm-db
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password
      - STATS-SERVER.URL=http://stats-server:9090

  ewm-db:
    image: postgres:13.7-alpine
    container_name: ewm-db
    ports:
      - "6541:5432"
    environment:
      - POSTGRES_DB=ewm-db
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password